package cn.wolfcode.car.domain;

import cn.wolfcode.car.enumpkg.AppointmentStatusEnum;
import com.alibaba.fastjson.JSON;
import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.*;
import org.springframework.format.annotation.DateTimeFormat;

import java.util.Date;
import java.util.HashMap;

@Getter
@Setter
@NoArgsConstructor
@AllArgsConstructor
@ToString
public class Appointment {
    private Long id;

    private String ano;

    private Integer status;

    //private Long categoryId;
    private SystemDictionaryItem category;

    private String info;

    private String contactTel;

    private String contactName;

    //private Long businessId;
    private Business business;
    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm")
    //@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    private Date createTime;
    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm")
    private Date appointmentTime;

    public String getStautsName() {
        return AppointmentStatusEnum.findName(this.status);
    }

    public Object getJson() {
        HashMap<String, Object> map = new HashMap<>();
        map.put("id", this.id);
        map.put("category", this.category.getId());
        map.put("business", this.business.getId());
        map.put("contactTel", this.contactTel);
        map.put("contactName", this.contactName);
        map.put("info", this.info);
        map.put("appointmentTime", this.appointmentTime);
        return JSON.toJSONString(map);
    }

}